<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BillController;
use App\Http\Controllers\BillTypeController;
use App\Http\Controllers\AIController;
use App\Http\Controllers\BalanceController;
use App\Http\Controllers\AIChatController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/
Route::post('/process-ai', [AIController::class, 'processText']);
Route::apiResource('bill-types', BillTypeController::class)
        ->parameters(['bill-types' => 'billType']) // 显式绑定路由参数
        ->except(['create', 'edit']); // 排除 HTML 表单方法
Route::prefix('auth')->group(function () {
    Route::post('register', [AuthController::class, 'register']); 
    Route::post('login', [AuthController::class, 'login']);
    
    Route::middleware('jwt.auth')->group(function () {
        Route::get('me', [AuthController::class, 'me']);
        Route::get('/bills/all', [BillController::class, 'getAll']);
        Route::post('/ai/chat-memory', [AIChatController::class, 'chatWithMemory'])->name('api.ai.chat.memory');
        Route::get('bills/by-month', [BillController::class, 'byMonth']);
        Route::apiResource('bills', BillController::class)
        ->parameters(['bills' => 'bill']) // 显式路由模型绑定
        ->except(['create', 'edit']); // 排除HTML表单方法
        Route::post('/update-avatar', [AuthController::class, 'updateAvatar']);
        Route::prefix('balance')->group(function () {
                Route::get('/', [BalanceController::class, 'getBalance']); // 获取当前余额
                
            });
    });

});

